var counter = 0;

var myArray = new Array();
myArray[0] = "id1";
myArray[1] = "id2";
myArray[2] = "id3";
myArray[3] = "id4";
myArray[4] = "id5";
myArray[5] = "id6";

function checkValid() {
	if(counter>2) {
		alert("Du har for mange valg"); //dette går ikke ann engang, haha.
		return false;
	}
	else {
		return true;
	}
}

function changeValue(elem) {
	if(elem.checked) {
    	counter++;
    	if(counter>1) {
    		document.getElementById('warning').innerHTML = "Du har valgt maks antall lovlige valg";
			
			for (i=0;i<myArray.length;i++){
				if(!(document.getElementById(myArray[i]).checked == true)) {
					document.getElementById(myArray[i]).disabled = true;
				}
			}
    	}
	}
	else {
		counter--;
    	if(counter<2) {
    		document.getElementById('warning').innerHTML = "";
			
			for (i=0;i<myArray.length;i++){
				if(!(document.getElementById(myArray[i]).checked == true)) {
					document.getElementById(myArray[i]).disabled = false;
				}
			}
    	}
	}
}